<%@ page import="com.dadie.dorm.pojo.Dormbuild" %><%--
  Created by IntelliJ IDEA.
  User: hp
  Date: 2023/7/29
  Time: 9:48
  To change this template use File | Settings | File Templadtes.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
    <title>Title</title>
    <%@ include file="header.jsp"%>


</head>
<body>
<form id="formId" class="layui-form layui-form-pane" action=""  method="post">
    <input type="hidden" name="id" value="${dormbuild.id}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" value="${dormbuild.name}" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">介紹</label>
        <div class="layui-input-block">
            <input type="text" name="introduce"  value="${dormbuild.introduce}"  autocomplete="off"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" onclick="submitForm()" class="layui-btn" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script>
    function submitForm() {
        $.post(
            '<%=request.getContextPath()%>/dormbuild?method=update',
            $('#formId').serialize(),
            function(result) {
                console.log(result);
                if (result.code == 0) {
                    mylayer.okMsg(result.msg)
                    setInterval(function() {
                        //关闭弹出框
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        //刷新父页面
                        window.parent.location.reload();
                    }, 2000)
                } else {
                    mylayer.errorMsg(result.msg);
                }
            },
            'json'
        );
    }
</script>
</body>
</html>